#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 10;
int a[N], n, m, highest;
ll sum;

bool check(int x)
{
	sum = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += max(0, a[i] - x);
	}
	if (sum >= m) return true;
	else return false;
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		highest = max(highest, a[i]);
	}
	int l = 0, r = highest;
	while (l + 1 < r)
	{
		int mid = (l + r) / 2;
		if (check(mid)) l = mid;
		else r = mid;
	}
	cout << l << endl;
	return 0;
}